home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 June / ChipCD 6.02.iso / macos / files / dragburn.sit / DragonBurn / Dragon Burn Installer / WebHelp / WEBHELP4.JS < prev   
Text File  |  2002-01-09  |  55KB  |  1,960 lines

  1. /////////////////////////////////////////////////////////////////////////////
  2. // RoboHELP« WebHelp 4 Dynamic HTML Effects Script
  3. // Copyright ⌐ 1998-2000 eHelp Corporation.  All rights reserved.
  4.  
  5. // Version= 4.10
  6.  
  7. // Warning:  Do not modify this file.  It is generated by RoboHELP« and changes will be overwritten.
  8.  
  9. //{{WH3_SYMBOL_SECTION
  10. var gstrNavFrmst = "navpane1.htm";
  11. var gstrTocDhtml = "tocdhtml.htm";
  12. var gstrIdxDhtml = "idxdhtml.htm";
  13. var gstrFtsDhtml = "ftsdhtml.htm";
  14. var gstrIniDhtml = "tocdhtml.htm";
  15. var gstrBlankhtml = "_blank.htm";
  16.  
  17. //}}WH3_SYMBOL_SECTION
  18.  
  19. var gnPageWidth = 0;
  20. var gnPageHeight = 0;
  21. var gstrColl = "";
  22. var gstrStyle = ""
  23. var gbNav4 = false;
  24. var gbIE4 = false;
  25. var gbIE = false;
  26. var gbIE5 = false;
  27. var gbIE55 = false;
  28. var gbTocLoaded = false;
  29. var gbIndexLoaded = false;
  30. var gbFtsLoaded = false;
  31. var gAgent = navigator.userAgent.toLowerCase(); 
  32. var gbMac = (gAgent.indexOf("mac") != -1);
  33.  
  34. var gbIndexInputEnable = false;
  35. var gIndexTopicArray = new Array();
  36. var gIndexKeywordArray = new Array();
  37. var gIndexLetterArray = new Array();
  38.  
  39. var gbFtsInputEnable = false;
  40. var gFtsKeywordArray = new Array();
  41. var gFtsTopicArray = new Array();
  42. var gFtsStopArray = new Array();
  43.  
  44. gbIE = (navigator.appName.indexOf("Microsoft") != -1);
  45. if (parseInt(navigator.appVersion) >= 4) {
  46.     gbNav4 = (navigator.appName == "Netscape");
  47.     gbIE4 = (navigator.appName.indexOf("Microsoft") != -1);
  48. }
  49. if (gbNav4) {
  50.     document.gnPageWidth = innerWidth;
  51.     document.gnPageHeight = innerHeight;
  52. //    document.captureEvents(Event.RESIZE);
  53. //    document.onresize = HandleResize;
  54. } else if (gbIE4) {
  55.     gstrStyle = ".style";
  56.     gstrColl = "all.";
  57.     if (gAgent.indexOf("msie 5") != -1) {
  58.         gbIE5 = true;
  59.     }
  60.     if (gAgent.indexOf("msie 5.5") != -1) {
  61.         gbIE55 = true;
  62.     }
  63. }
  64.  
  65. function HandleResize()
  66. {
  67.     if (innerWidth != window.document.gnPageWidth || innerHeight != window.document.gnPageHeight) {
  68.         if (window.document.gnPageWidth == 0) {
  69.             window.document.gnPageWidth = innerWidth;
  70.             window.document.gnPageHeight = innerHeight;
  71.         } else {
  72.             window.document.gnPageWidth = innerWidth;
  73.             window.document.gnPageHeight = innerHeight;
  74.             window.document.location.reload();
  75.         }
  76.         return false;
  77.     }
  78. }
  79.  
  80.  
  81. function FindTopLevelLayer(strID)
  82. {
  83.     if (gbNav4) {
  84.         return FindTopLevelLayerNS(strID);
  85.     } else if (gbIE4) {
  86.         var obj = eval("document.all." + strID);
  87.         return obj;
  88.     }
  89.     return null;
  90. }
  91.  
  92. function FindTopLevelLayerNS(strID)
  93. {
  94.     for (var iLayer = 0; iLayer < window.document.layers.length; iLayer++) {
  95.         if (window.document.layers[iLayer].id == strID) {
  96.             return window.document.layers[iLayer];
  97.         }
  98.     }
  99.  
  100.     // This section is added to the search because when the scrollbar is
  101.     // added, Netscape messes up the layer list. This is another way
  102.     // of getting to the layers
  103.     if (window.document.layers.length > 0) {
  104.         var iLayer = 0;
  105.         var objLayer = window.document.layers[0];
  106.         while ((iLayer < 20) && (objLayer != null)) {
  107.             if (objLayer.id == strID) {
  108.                 return objLayer;
  109.             }
  110.             iLayer++;
  111.             objLayer = objLayer.above;
  112.         }
  113.     }
  114.     return null;
  115. }
  116.  
  117. function GetAttribObject(obj)
  118. {
  119.     var objAttrib = null;
  120.     if (typeof obj == "string") {
  121.         objAttrib = eval("document." + gstrColl + obj + gstrStyle);
  122.     } else {
  123.         objAttrib = obj;
  124.     }
  125.     return objAttrib;
  126. }
  127.  
  128.  
  129. function TabFrame()
  130. {
  131.     if (gbNav4) {
  132.         return Tabs;
  133.     } else {
  134.         return document.frames['Tabs'];
  135.     }
  136. }
  137.  
  138. function NavFrame()
  139. {
  140.     if (gbNav4) {
  141.         return Navigation;
  142.     } else {
  143.         return document.frames['Navigation'];
  144.     }
  145. }
  146.  
  147. function GetIFrameByDiv(div)
  148. {
  149.     var cIframe;
  150.     if ((frames.length > 0) &&
  151.         (div != null) &&
  152.         (div.id != null))
  153.     {
  154.         if (div.id == "TocNav")
  155.             cIframe = frames[0];
  156.         else if (div.id == "IndexNav")
  157.             cIframe = frames[1];
  158.         else if (div.id == "FtsNav")
  159.             cIframe = frames[2];            
  160.     }
  161.     return cIframe;
  162. }
  163.  
  164.  
  165. function ShowDiv(strDiv, bShow)
  166. {
  167.     var Div = FindTopLevelLayer(strDiv);
  168.     if (Div == null) {
  169.         return;
  170.     }
  171.  
  172.     if (gbNav4) {
  173.         if (bShow == true) {
  174.             Div.visibility = 'show';
  175. //            Div.left = 0;
  176.             Div.moveToAbsolute(0, 0);
  177.         } else {
  178.             Div.visibility = 'hide';
  179. //            Div.left = -2000;
  180.             Div.moveToAbsolute(-2000, 0);
  181.         }
  182.     } else {
  183.         if (gbIE55)
  184.         {
  185.             var curIframe = GetIFrameByDiv(Div);
  186.             if (bShow)
  187.             {
  188.                Div.style.zIndex = 3;
  189.                if (curIframe != null)  
  190.                {
  191.                 curIframe.frameElement.style.zIndex=3;
  192.                 curIframe.frameElement.style.visibility = "visible";
  193.                }
  194.             }
  195.             else
  196.             {
  197.                Div.style.zIndex = 2;
  198.                if (curIframe != null)
  199.                {
  200.                 curIframe.frameElement.style.zIndex= 2;
  201.                 curIframe.frameElement.style.visibility = "hidden";
  202.                }
  203.             }
  204.         }
  205.  
  206.         Div.style.visibility = (bShow == true) ? 'visible' : 'hidden';
  207.     }
  208.     return;
  209. }
  210.  
  211. function LoadTocContent(TocDiv)
  212. {    
  213.     gbTocLoaded = true;
  214.     return;
  215. }
  216.  
  217. function SyncTocContent(strtocURL)
  218. {
  219.     var TocDiv = this.FindTopLevelLayer('TocNav');
  220.     if (TocDiv.document.all.TocIFrame == null) return;
  221.  
  222.     var strFile = TocDiv.document.all.TocIFrame.document.location.href;
  223.     var strHash = TocDiv.document.all.TocIFrame.document.location.hash;
  224.     if (strHash.length > 0) {
  225.         strFile = strFile.substring(0, strFile.length - strHash.length);
  226.     }
  227.  
  228.     var strHash = "";
  229.     if (strtocURL.length > 0)  {
  230.         strHash = "#" + strtocURL;
  231.     } 
  232.     if (strHash.length > 0) {
  233.         strFile += strHash;
  234.     }
  235.     if (gbNav4) {
  236.         TocDiv.src = strFile;
  237.     } else if (gbIE4) {
  238.         // no refresh.
  239.         // but we need to switch div , if need.
  240.         if (parent.TabFrame().document.images['TocTab'] != null) {
  241.             parent.TabFrame().document.images['TocTab'].src='bssctab1.gif';
  242.         }
  243.         if (parent.TabFrame().document.images['IndexTab'] != null) {
  244.             parent.TabFrame().document.images['IndexTab'].src='bssctab4.gif';
  245.         }
  246.         if (parent.TabFrame().document.images['FtsTab'] != null) {
  247.             parent.TabFrame().document.images['FtsTab'].src='bssctab6.gif';
  248.         }            
  249.         ShowDiv('TocNav', true);
  250.         ShowDiv('IndexNav', false);
  251.         ShowDiv('FtsNav', false);
  252.         TOCFocusA();
  253.         if (document.frames['TocIFrame'] != null) // sure. we can access this iframe.
  254.             document.frames['TocIFrame'].window.NavBar_SyncToc(strtocURL);
  255.  
  256. //        parent.document.strtocURL = strtocURL;
  257. //        TocDiv.document.location.reload();
  258.     }
  259.     gbTocLoaded = true;
  260.     return;
  261. }
  262.  
  263. function TOCFocusA()
  264. {
  265.     if (gbIE55) 
  266.     {
  267.         var TocDiv = FindTopLevelLayer('TocNav');
  268.         if (TocDiv && TocDiv.document && TocDiv.document.frames['TocIFrame'])
  269.         {
  270.             TocDiv = TocDiv.document.frames['TocIFrame'];
  271.             if (TocDiv)
  272.                 TocDiv.focus();
  273.         }
  274.     }
  275. }
  276.  
  277. function LoadIndexContent(IndexDiv)
  278. {
  279.     var strFile = location.href;
  280.     var nPosFile = strFile.indexOf(gstrNavFrmst);
  281.     strFile = strFile.substring(0, nPosFile);
  282.     strFile += gstrIdxDhtml;
  283.     if (gbNav4) {
  284.         IndexDiv.src = strFile;
  285.     } else if (gbIE4) {
  286. //        IndexDiv.document.frames['IndexIFrame'].location.href = strFile;
  287.         IndexDiv.document.all.IndexIFrame.src = strFile;
  288.     }
  289.     gbIndexLoaded = true;
  290.     return;
  291. }
  292.  
  293. function LoadFtsContent(FtsDiv)
  294. {
  295.     var strFile = location.href;
  296.     var nPosFile = strFile.indexOf(gstrNavFrmst);
  297.     strFile = strFile.substring(0, nPosFile);
  298.     strFile += gstrFtsDhtml;
  299.     if (gbNav4) {
  300.         FtsDiv.src = strFile;
  301.     } else if (gbIE4) {
  302. //        FtsDiv.document.frames['FtsIFrame'].location.href = strFile;
  303.         FtsDiv.document.all.FtsIFrame.src = strFile;
  304.     }
  305.     gbFtsLoaded = true;
  306.     return;
  307. }
  308.  
  309.  
  310. function TimeoutChangeToTOC()
  311. {
  312.     if (!gbTocLoaded) {
  313.         var TocDiv = window.NavFrame().FindTopLevelLayer('TocNav');
  314.         if (TocDiv != null) {
  315.             LoadTocContent(TocDiv);
  316.         }
  317.     }
  318.     if (window.TabFrame().document.images['TocTab'] != null) {
  319.         window.TabFrame().document.images['TocTab'].src='bssctab1.gif';
  320.     }
  321.     if (window.TabFrame().document.images['IndexTab'] != null) {
  322.         window.TabFrame().document.images['IndexTab'].src='bssctab4.gif';
  323.     }
  324.     if (window.TabFrame().document.images['FtsTab'] != null) {
  325.         window.TabFrame().document.images['FtsTab'].src='bssctab6.gif';
  326.     }
  327.     window.NavFrame().ShowDiv('TocNav', true);
  328.     window.NavFrame().ShowDiv('IndexNav', false);
  329.     window.NavFrame().ShowDiv('FtsNav', false);
  330.     if (gbNav4 && window.NavFrame().window.NSscrollbar) {
  331.         NavFrame().window.NSscrollbar.SetActiveLayer(NavFrame().FindTopLevelLayer('TocNav'));
  332.     }
  333. }
  334.  
  335.  
  336. function ChangeToTOC()
  337. {
  338.     setTimeout("TimeoutChangeToTOC();", 50);
  339.     return;
  340. }
  341.  
  342. function SelectTOC()
  343. {
  344.     if (!gbTocLoaded) {
  345.         var TocDiv = NavFrame().FindTopLevelLayer('TocNav');
  346.         if (TocDiv != null) {
  347.             LoadTocContent(TocDiv);
  348.         }
  349.     }
  350.     if (TabFrame().document.images['TocTab'] != null) {
  351.         TabFrame().document.images['TocTab'].src='bssctab1.gif';
  352.     }
  353.     if (TabFrame().document.images['IndexTab'] != null) {
  354.         TabFrame().document.images['IndexTab'].src='bssctab4.gif';
  355.     }
  356.     if (TabFrame().document.images['FtsTab'] != null) {
  357.         TabFrame().document.images['FtsTab'].src='bssctab6.gif';
  358.     }
  359.     NavFrame().ShowDiv('TocNav', true);
  360.     NavFrame().ShowDiv('IndexNav', false);
  361.     NavFrame().ShowDiv('FtsNav', false);
  362.     if (gbNav4 && NavFrame().window.NSscrollbar) {
  363.         NavFrame().window.NSscrollbar.SetActiveLayer(NavFrame().FindTopLevelLayer('TocNav'));
  364.     }
  365.  
  366.     setTimeout("TOCFocus()", 200);
  367. }
  368.  
  369. function TimeoutChangeToIndex()
  370. {
  371.     if (!gbIndexLoaded) {
  372.         var IndexDiv = window.NavFrame().FindTopLevelLayer('IndexNav');
  373.         if (IndexDiv != null) {
  374.             LoadIndexContent(IndexDiv);
  375.         }
  376.     }
  377.     if (window.TabFrame().document.images['TocTab'] != null) {
  378.         window.TabFrame().document.images['TocTab'].src='bssctab2.gif';
  379.     }
  380.     if (window.TabFrame().document.images['IndexTab'] != null) {
  381.         window.TabFrame().document.images['IndexTab'].src='bssctab3.gif';
  382.     }
  383.     if (window.TabFrame().document.images['FtsTab'] != null) {
  384.         window.TabFrame().document.images['FtsTab'].src='bssctab6.gif';
  385.     }
  386.     window.NavFrame().ShowDiv('TocNav', false);
  387.     window.NavFrame().ShowDiv('IndexNav', true);
  388.     window.NavFrame().ShowDiv('FtsNav', false);
  389.     if (gbNav4 && window.NavFrame().window.NSscrollbar) {
  390.         NavFrame().window.NSscrollbar.SetActiveLayer(NavFrame().FindTopLevelLayer('IndexNav'));
  391.     }
  392. }
  393.  
  394.  
  395. function ChangeToIndex()
  396. {
  397.     setTimeout("TimeoutChangeToIndex();", 50);
  398. }
  399.  
  400. function SelectIndex()
  401. {
  402.     if (!gbIndexLoaded) {
  403.         var IndexDiv = NavFrame().FindTopLevelLayer('IndexNav');
  404.         if (IndexDiv != null) {
  405.             LoadIndexContent(IndexDiv);
  406.         }
  407.     }
  408.     if (TabFrame().document.images['TocTab'] != null) {
  409.         TabFrame().document.images['TocTab'].src='bssctab2.gif';
  410.     }
  411.     if (TabFrame().document.images['IndexTab'] != null) {
  412.         TabFrame().document.images['IndexTab'].src='bssctab3.gif';
  413.     }
  414.     if (TabFrame().document.images['FtsTab'] != null) {
  415.         TabFrame().document.images['FtsTab'].src='bssctab6.gif';
  416.     }
  417.     NavFrame().ShowDiv('TocNav', false);
  418.     NavFrame().ShowDiv('IndexNav', true);
  419.     NavFrame().ShowDiv('FtsNav', false);
  420.     if (gbNav4 && NavFrame().window.NSscrollbar) {
  421.         NavFrame().window.NSscrollbar.SetActiveLayer(NavFrame().FindTopLevelLayer('IndexNav') );
  422.     }
  423.  
  424.     setTimeout("IndexFocus()", 200);
  425. }
  426.  
  427.  
  428. function SelectFTS()
  429. {
  430.     var FtsDiv = NavFrame().FindTopLevelLayer('FtsNav');
  431.     if (!gbFtsLoaded) {
  432.         if (FtsDiv != null) {
  433.             LoadFtsContent(FtsDiv);
  434.         }
  435.     }
  436.     if (TabFrame().document.images['TocTab'] != null) {
  437.         TabFrame().document.images['TocTab'].src='bssctab2.gif';
  438.     }
  439.     if (TabFrame().document.images['IndexTab'] != null) {
  440.         TabFrame().document.images['IndexTab'].src='bssctab4.gif';
  441.     }
  442.     if (TabFrame().document.images['FtsTab'] != null) {
  443.         TabFrame().document.images['FtsTab'].src='bssctab5.gif';
  444.     }
  445.     NavFrame().ShowDiv('TocNav', false);
  446.     NavFrame().ShowDiv('IndexNav', false);
  447.     NavFrame().ShowDiv('FtsNav', true);
  448.     if (gbNav4 && NavFrame().window.NSscrollbar) {
  449.         NavFrame().window.NSscrollbar.SetActiveLayer(NavFrame().FindTopLevelLayer('FtsNav'));
  450.     }
  451.  
  452.     setTimeout("FTSFocus()", 200);
  453. }
  454.  
  455. function TOCFocus()
  456. {
  457.     if (gbIE55) 
  458.     {
  459.         var TocDiv = NavFrame().FindTopLevelLayer('TocNav');
  460.         if (TocDiv && TocDiv.document && TocDiv.document.frames['TocIFrame'])
  461.         {
  462.             TocDiv = TocDiv.document.frames['TocIFrame'];
  463.             if (TocDiv)
  464.                 TocDiv.focus();
  465.         }
  466.     }
  467. }
  468.  
  469.  
  470. function FTSFocus()
  471. {
  472.     var FtsDiv = NavFrame().FindTopLevelLayer('FtsNav');
  473.     if (gbIE4) {
  474.         if (FtsDiv && FtsDiv.document && FtsDiv.document.frames['FtsIFrame'] &&
  475.             FtsDiv.document.frames['FtsIFrame'].frames['ftsform']) 
  476.             FtsDiv = FtsDiv.document.frames['FtsIFrame'].frames['ftsform'];
  477.     }
  478.  
  479.     if (FtsDiv && FtsDiv.FtsInputForm != null) {
  480.         FtsDiv.FtsInputForm.ftsField.focus();
  481.     }
  482. }
  483.  
  484. function IndexFocus()
  485. {
  486.  
  487.     var IndexDiv = NavFrame().FindTopLevelLayer('IndexNav');
  488.     if (gbIE4) {
  489.         if (IndexDiv && IndexDiv.document && IndexDiv.document.frames['IndexIFrame'] &&
  490.             IndexDiv.document.frames['IndexIFrame'].frames['idxform']) 
  491.             IndexDiv = IndexDiv.document.frames['IndexIFrame'].frames['idxform'];
  492.     }
  493.     if (IndexDiv && IndexDiv.IndexInputForm != null) {
  494.         IndexDiv.IndexInputForm.keywordField.focus();
  495.     }
  496. }
  497.  
  498. function SelectInitialTab()
  499. {
  500.     // Create the necessary IFrames for IE
  501.     if (gbIE4) {
  502.         if (FindTopLevelLayer('TocNav') != null) {
  503.             var nIFrameHeight = FindTopLevelLayer('TocNav').style.pixelHeight - 10;
  504.             var strIFrame = '<IFRAME ID="TocIFrame" SRC="' + gstrTocDhtml + '" BORDER=0 FRAMEBORDER=no STYLE="position:absolute; left:2%; width:92%; height:';
  505.             if (gbMac) {
  506.                 strIFrame += nIFrameHeight + 'px;"></IFRAME>';
  507.             } else {
  508.                 strIFrame += '100%;"></IFRAME>';
  509.             }
  510.             FindTopLevelLayer('TocNav').innerHTML = strIFrame;
  511.         }
  512.         if (FindTopLevelLayer('IndexNav') != null) {
  513.             var nIFrameHeight = FindTopLevelLayer('IndexNav').style.pixelHeight - 10;
  514.             var strIFrame = '<IFRAME ID="IndexIFrame" SRC="' + gstrBlankhtml + '" BORDER=0 FRAMEBORDER=no STYLE="position:absolute; left:2%; width:92%; height:';
  515.             if (gbMac) {
  516.                 strIFrame += nIFrameHeight + 'px;"></IFRAME>';
  517.             } else {
  518.                 strIFrame += '100%;"></IFRAME>';
  519.             }
  520.             FindTopLevelLayer('IndexNav').innerHTML = strIFrame;
  521.         }
  522.  
  523.         if (FindTopLevelLayer('FtsNav') != null) {
  524.             var nIFrameHeight = FindTopLevelLayer('FtsNav').style.pixelHeight - 10;
  525.             var strIFrame = '<IFRAME ID="FtsIFrame" SRC="' + gstrBlankhtml + '" BORDER=0 FRAMEBORDER=no STYLE="position:absolute; left:2%; width:92%; height:';
  526.             if (gbMac) {
  527.                 strIFrame += nIFrameHeight + 'px;"></IFRAME>';
  528.             } else {
  529.                 strIFrame += '100%;"></IFRAME>';
  530.             }
  531.             FindTopLevelLayer('FtsNav').innerHTML = strIFrame;
  532.         }
  533.     }
  534.  
  535.     // Call the real selection function
  536.     setTimeout("SelectInitTabReal()", 50);
  537. }
  538.  
  539. function SelectInitTabReal()
  540. {
  541.     parent.gbTocLoaded = false;
  542.     parent.gbIndexLoaded = false;
  543.     parent.gbFtsLoaded = false;
  544.  
  545.     if (gstrIniDhtml == gstrTocDhtml)    {
  546.         parent.SelectTOC();
  547.     } else if (gstrIniDhtml == gstrIdxDhtml) {
  548.         parent.SelectIndex();
  549.     } else if (gstrIniDhtml == gstrFtsDhtml) {
  550.         parent.SelectFTS();
  551.     }
  552.  
  553. //    if (FindTopLevelLayer('TocNav') != null) {
  554. //        parent.SelectTOC();
  555. //    } else if (FindTopLevelLayer('IndexNav') != null) {
  556. //        parent.SelectIndex();
  557. //    } else if (FindTopLevelLayer('FtsNav') != null) {
  558. //        parent.SelectFTS();
  559. //    }
  560. }
  561.  
  562.  
  563. //////////////////////////////////////////////////////////////////////////////////////////////////////////
  564. //
  565. // Index code
  566. //
  567. //////////////////////////////////////////////////////////////////////////////////////////////////////////
  568.  
  569. var gbIndexLayerInit = false;
  570. function IndexInitPage()
  571. {
  572.     parent.gbIndexLayerInit = false;
  573.     if (gbNav4) {
  574.         TocBuildLayerArrayNS();
  575.         onLoad = TocArrangeAllLayerNS();
  576.     } else if (gbIE4) {
  577.  
  578.         // Mark all Index blocks as "expanded"
  579.         var tempColl = document.all.tags("DIV");
  580.         for (var i = 0; i < tempColl.length; i++) {
  581.             if (tempColl(i).className == "child") tempColl(i).style.display = "block";
  582.         }
  583.  
  584.         // Make an array of parents so we can access them directly
  585.         var tempColl = document.all.tags("DIV");
  586.         var iLetterIndex = 0;
  587.         var nACharCode = "A".charCodeAt(0);
  588.         for (var i = 0; i < tempColl.length; i++) {
  589.             if (tempColl(i).className == "parent") {
  590.                 if (tempColl(i).innerText == "#") {
  591.                     gIndexLetterArray[0] = tempColl(i);
  592.                 } else {
  593.                     iLetterIndex = tempColl(i).innerText.charCodeAt(0);
  594.                     iLetterIndex -= nACharCode;
  595.                     iLetterIndex += 1;
  596.                     gIndexLetterArray[iLetterIndex] = tempColl(i);
  597.                 }
  598.             }
  599.         }
  600.     }
  601.     setTimeout("parent.gbIndexLayerInit = true;",1000);
  602.     return;
  603. }
  604.  
  605. function IndexWriteClassStyle()
  606. {
  607.     document.write("<STYLE TYPE='text/css'>");
  608.     if (gbNav4) {
  609.         document.write(".IndexItem {visibility:inherit; font-size:9pt;}");
  610.         document.write(".parent {font-size:10pt; position:absolute; visibility:hidden}");
  611.         document.write(".child {font-size:10pt; position:absolute; visibility:hidden}");
  612.         document.write("BLOCKQUOTE {margin-top:0pt; margin-bottom:0pt; margin-left:-15pt;}");
  613.         document.write("DIV {margin-left:10pt; margin-top:0pt; margin-bottom:0pt}");
  614.         document.write("P {margin-top:0pt; margin-bottom:0pt}");
  615.         document.write("A:link {text-decoration: none; color: 000000}");
  616.         document.write("A:visited {text-decoration: none; color: 333333}");
  617.         document.write("A:active {text-decoration: none; background-color: #cccccc}");
  618.         document.write("A:hover {text-decoration: underline; color: 007f00}");
  619.     } else if (gbIE4) {
  620.         if (gbMac) {
  621.             if (gbIE5) {
  622.                 document.write(".IndexItem {visibility:inherit; font-size:10pt;}");
  623.                 document.write(".parent {font-size:10pt;}");
  624.                 document.write("BLOCKQUOTE {margin-top:0pt; margin-bottom:0pt; margin-left:15pt;}");
  625.                 document.write("P {font-family:'Arial'; color:#cccccc; font-size:10pt; margin-top:0pt; margin-bottom:0pt;}");
  626.                 document.write("H6 {font-family:'Arial'; color:#cccccc; font-size:10pt; margin-top:0pt; margin-bottom:0pt; font-style:normal;font-weight:normal;}");
  627.                 document.write("H6.firstsub {font-family:'Arial'; color:#cccccc; font-size:10pt; margin-top:0pt; margin-bottom:0pt; font-style:normal;font-weight:normal;}");
  628.             } else {
  629.  
  630.                 document.write(".IndexItem {visibility:inherit; font-size:12pt;}");
  631.                 document.write(".parent {font-size:14pt;}");
  632.                 document.write("BLOCKQUOTE {margin-top:0pt; margin-bottom:0pt; margin-left:15pt;}");
  633.                 document.write("P {font-family:'Arial'; color:#cccccc; font-size:12pt; margin-top:0pt; margin-bottom:0pt;}");
  634.                 document.write("H6 {font-family:'Arial'; color:#cccccc; font-size:12pt; margin-top:0pt; margin-bottom:0pt; font-style:normal;font-weight:normal;}");
  635.                 document.write("H6.firstsub {font-family:'Arial'; color:#cccccc; font-size:12pt; margin-top:-10pt; margin-bottom:0pt; font-style:normal;font-weight:normal;}");
  636.             }
  637.         } else {
  638.             document.write(".IndexItem {visibility:inherit; font-size:8pt;}");
  639.             document.write(".parent {font-size:10pt;}");
  640.             document.write("BLOCKQUOTE {margin-top:0pt; margin-bottom:0pt; margin-left:15pt;}");
  641.             document.write("P {font-family:'Arial'; color:#cccccc; font-size:9pt; margin-top:0pt; margin-bottom:0pt;}");
  642.             document.write("H6 {font-family:'Arial'; color:#cccccc; font-size:9pt; margin-top:0pt; margin-bottom:0pt; font-style:normal;font-weight:normal;}");
  643.         }
  644.         document.write(".child {display:block}");
  645.         document.write("DIV {margin-top:0pt; margin-bottom:0pt}");
  646.         document.write("A:link {text-decoration: none; color: 000000}");
  647.         document.write("A:visited {text-decoration: none; color: 333333}");
  648.         document.write("A:active {text-decoration: none; background-color: #cccccc}");
  649.         document.write("A:hover {text-decoration: underline; color: 007f00}");
  650.     }
  651.     document.write("</STYLE>");
  652.     return;
  653. }
  654.  
  655. //Define variable arguments as: strTitle, strUrl
  656. function TopicEntry() 
  657. {
  658.     var argLen = TopicEntry.arguments.length;
  659.     this.strTitle = TopicEntry.arguments[0];
  660.     this.strURL = TopicEntry.arguments[1];
  661. }
  662.  
  663. //Define variable arguments as: strKeyword [,strTopicIndex]*
  664. function IndexKeywordEntry() 
  665. {
  666.     var argLen = IndexKeywordEntry.arguments.length;
  667.     this.strKeyword = IndexKeywordEntry.arguments[0];
  668.     this.arrayTopics = new Array();
  669.  
  670.     // Now add all of the topic entries
  671.     for (var i=0; i < argLen - 1; i++) {
  672.         this.arrayTopics[i] = IndexKeywordEntry.arguments[i + 1];
  673.     }
  674. }
  675.  
  676.  
  677. function IndexBody()
  678. {
  679.     // Get the appropriate item to add items to
  680.     var layerFind = null;
  681.     if (gbIE4) {
  682.         layerFind = parent.document.frames['idxbody'];
  683.     } else if (gbNav4) {
  684.         layerFind = parent.document.idxbody.document;
  685.     }
  686.     
  687.     return layerFind;
  688. }
  689.  
  690. function IndexForm()
  691. {
  692.     // Get the appropriate item to add items to
  693.     var layerFind = null;
  694.     if (gbIE4) {
  695.         layerFind = parent.document.frames['idxform'];
  696.     } else if (gbNav4) {
  697.         layerFind = parent.document.idxform.document;
  698.     }
  699.     
  700.     return layerFind;
  701. }
  702.  
  703. function IndexExpandIt(elId, bForceOpen) 
  704. {
  705.     var layerChild = null;
  706.     if (gbIE4) {
  707.         layerChild = TocExpandIE(elId, false, bForceOpen);
  708.  
  709.         if (!bForceOpen) {
  710.             var nNewScroll = document.body.scrollTop;
  711.             if (layerChild.style.display == "block") {
  712.                 var nItemTop = layerChild.offsetTop;
  713.                 var nItemBottom = nItemTop + layerChild.offsetHeight;
  714.                 // Make sure the bottom is visible if possible
  715.                 if (document.body.scrollTop + document.body.clientHeight < nItemBottom) {
  716.                     nNewScroll = nItemBottom - document.body.clientHeight;
  717.                 }
  718.                 // If expanded item is bigger than the client area, scroll the item to the top
  719.                 if (nItemBottom - nItemTop > document.body.clientHeight) {
  720.                     nNewScroll = nItemTop - 20;
  721.                 }
  722.             }
  723.             document.body.scrollTop = nNewScroll;
  724.         }
  725.     } else if (gbNav4) {
  726.         layerChild = TocExpandNS(elId, false, bForceOpen);
  727.         if (window.NSscrollbar != null) {
  728.             window.NSscrollbar.SetContentHeight(nextY);
  729.             window.NSscrollbar.SetContentWidth(nextX);
  730.         }
  731.     }
  732.     return layerChild;
  733. }
  734.  
  735.  
  736. function IndexInputEnable(bEnable)
  737. {
  738.     gbIndexInputEnable = bEnable;
  739.     return;
  740. }
  741.  
  742. function IndexInputSubmit()
  743. {
  744.     IndexLookup(true);
  745.     return;
  746. }
  747.  
  748. //Initize the site
  749. function IndexSiteInit()
  750. {
  751.   if (!window.Array) return;
  752.  
  753.   if (gbNav4) document.captureEvents(Event.KEYUP);
  754.   document.onkeyup = IndexLookupKeydown;
  755. }
  756.  
  757. function IndexLookupKeydown() 
  758. {
  759.     IndexLookup(false);
  760. }
  761.  
  762. function IndexLookup(bCR) 
  763. {
  764.     if (!parent.gbIndexLayerInit) {
  765.         return; 
  766.     }
  767.  
  768.     if (!gbIndexInputEnable && !gbMac) {
  769.         return;
  770.     }
  771.  
  772.     var strInput = document.IndexInputForm.keywordField.value.toUpperCase();
  773.     if (strInput != "") {
  774.         IndexSiteDisplay(strInput, bCR);
  775.     }
  776.  
  777.     if (gbMac) {
  778.         document.IndexInputForm.keywordField.focus();
  779.     }
  780.  
  781.     return;
  782. }
  783.  
  784. function  IndexSiteDisplay(strInput, bCR)
  785. {
  786.     // Get the topmost Index layer
  787.     var IndexDiv = IndexBody();
  788.  
  789.     // Get the layer for the first letter
  790.     var cFirst = strInput.charAt(0);
  791.     cFirst.toUpperCase();
  792.     var layerFirst = null;
  793.     if (gbNav4) {
  794.         for (var iLayer = 0; iLayer < document.layers.length; iLayer++) {
  795.             if ((document.layers[iLayer].id.indexOf("Parent") != -1) &&
  796.                 (document.layers[iLayer].id.charAt(0) == cFirst)) {
  797.                 layerFirst = document.layers[iLayer];
  798.                 break;
  799.             }
  800.         }
  801.         if (layerFirst == null) {
  802.             layerFirst = document.BookR0000000Parent;
  803.         }
  804.     } else if (gbIE4) {
  805.  
  806.         var iLetterIndex = cFirst.charCodeAt(0) - "A".charCodeAt(0) + 1;
  807.         if ((iLetterIndex < 1) || (iLetterIndex > 26)) {
  808.             layerFirst = IndexDiv.gIndexLetterArray[0];
  809.         } else {
  810.             layerFirst = IndexDiv.gIndexLetterArray[iLetterIndex];
  811.         }
  812.     }
  813.  
  814.     // If we didn't find anything then return - something went terribly wrong
  815.     if (layerFirst == null) {
  816.         return;
  817.     }
  818.  
  819.     // Expand the first layer
  820.     var strLayerID = layerFirst.id;
  821.     var iParent = strLayerID.indexOf("Parent");
  822.     strLayerID = strLayerID.substr(0, iParent);
  823.  
  824.     var layerChild = IndexDiv.IndexExpandIt(strLayerID, true);
  825.  
  826.     // Find the first child that "matches" the item we are searchig for
  827.     var MatchingItem = null;
  828.     if (gbNav4) {
  829.     } else if (gbIE4) {
  830.  
  831.         var tempColl = layerChild.all.tags("P");
  832.         if (tempColl.length == 0) {
  833.             MatchingItem = layerChild;
  834.         } else {
  835.             var iStart = 0;
  836.             var iEnd = tempColl.length - 1;
  837.             var iMid = 0;
  838.             var strItemUpper = "";
  839.             while (iStart <= iEnd) {
  840.                 iMid = iStart + iEnd;
  841.                 iMid >>= 1;
  842.                 strItemUpper = tempColl(iMid).innerText;
  843.                 strItemUpper = strItemUpper.toUpperCase();
  844.                 if (strItemUpper.indexOf(strInput) == 0) {
  845.                     break;
  846.                 } else if (strItemUpper > strInput) {
  847.                     iEnd = iMid - 1;
  848.                 } else {
  849.                     iStart = iMid + 1;
  850.                 }
  851.             }
  852.  
  853.             // Search backward to find the first one that partially matches
  854.             var iMatch = 0;
  855.             for (var iMatch = iMid; iMatch >= 0; iMatch--) {
  856.                 strItemUpper = tempColl(iMatch).innerText;
  857.                 strItemUpper = strItemUpper.toUpperCase();
  858.                 if (strItemUpper.indexOf(strInput) != 0) {
  859.                     break;
  860.                 }
  861.             }
  862.             if (iMatch != iMid) {
  863.                 if (iMatch >= 0) {
  864.                     if (iMatch < tempColl.length - 1) {
  865.                         iMid = iMatch + 1;
  866.                     } else {
  867.                         iMid = iMatch;
  868.                     }
  869.                 } else {
  870.                     iMid = 0;
  871.                 }
  872.             }
  873.             MatchingItem = tempColl(iMid);
  874.         }
  875.     }
  876.  
  877.     // Scroll to the closest matching item
  878.     if (MatchingItem) {
  879.         if (gbNav4) {
  880.         } else if (gbIE4) {
  881.             IndexDiv.document.body.scrollTop = MatchingItem.offsetTop;
  882.  
  883.             // Set the focus on the selected hyperlink (if there is one)
  884.             if (gbIE5) {
  885.                 tempColl = MatchingItem.all.tags("A");
  886.                 if (tempColl.length > 0) {
  887.                     // If a carriage return was used then simulate a click
  888.                     if (bCR) {
  889.                         tempColl(0).click();
  890.                     } else {
  891.                         // Simply set the focus to the hyperlink
  892.                         if (gbIE55) {
  893.                            HighLightElement(tempColl(0));
  894.                         } else {
  895.                            tempColl(0).focus();
  896.                         }
  897.                     }
  898.                     IndexForm().document.IndexInputForm.keywordField.focus();
  899.                 }
  900.             }
  901.         }
  902.     }
  903.  
  904.     return;
  905. }
  906.  
  907. var gBsLastHighLightElement = null;
  908. var gBsOrgBackgroundColor = null;
  909.  
  910. function HighLightElement(objAnchor)
  911. {
  912.     if (gBsOrgBackgroundColor == null)
  913.         gBsOrgBackgroundColor  = objAnchor.currentStyle.backgroundcolor;
  914.  
  915.     resetHighLight();
  916.     objAnchor.style.backgroundColor = "lightgrey";
  917.     gBsLastHighLightElement = objAnchor;
  918. }
  919.  
  920. function resetHighLight()
  921. {
  922.     if (gBsLastHighLightElement != null)
  923.     {
  924.           if (gBsOrgBackgroundColor != null)
  925.             gBsLastHighLightElement.style.backgroundColor = gBsOrgBackgroundColor ;    
  926.         else        
  927.             gBsLastHighLightElement.style.backgroundColor = "transparent" ;            
  928.     }
  929. }
  930.  
  931. //////////////////////////////////////////////////////////////////////////////////////////////////////////
  932. //
  933. // TOC code
  934. //
  935. //////////////////////////////////////////////////////////////////////////////////////////////////////////
  936. var imgBookClose ="bssctoc1.gif";
  937. var imgBookOpen  ="bssctoc2.gif";
  938.  
  939. var  elTocArray = new Array();
  940. var  elTocArrayNum = 0;
  941.  
  942. function TocWriteClassStyle()
  943. {
  944.     document.write("<STYLE TYPE='text/css'>");
  945.     if (gbNav4) {
  946.         document.write(".parent {position:absolute; visibility:hidden}");
  947.         document.write(".child {position:absolute; visibility:hidden}");
  948.         document.write("BLOCKQUOTE {margin-top:0pt; margin-bottom:0pt; margin-left:-15pt;}");
  949.         document.write("DIV {margin-top:0pt; margin-bottom:0pt}");
  950.         document.write("P {margin-top:0pt; margin-bottom:0pt}");
  951.         document.write("PRE {margin-top:0pt; margin-bottom:0pt}");
  952.     } else if (gbIE4) {
  953.         if (gbMac) {
  954.             if (gbIE5){
  955.                 document.write(".parent {font-size:10pt;}");
  956.                 document.write("P {font-family:'Arial'; font-size:10pt; margin-top:0pt; margin-bottom:0pt;}");
  957.                 document.write("PRE {font-family:'Arial'; font-size:10pt; margin-top:0pt; margin-bottom:0pt;}");
  958.                 document.write("BLOCKQUOTE {margin-top:0pt; margin-bottom:0pt; margin-left:15pt;}");
  959.                 document.write("DIV {margin-top:0pt; margin-bottom:0pt}");
  960.             } else {
  961.                 document.write(".parent {font-size:14pt;}");
  962.                 document.write("P {font-family:'Arial'; font-size:12pt; margin-top:0pt; margin-bottom:0pt;}");
  963.                 document.write("PRE {font-family:'Arial'; font-size:12pt; margin-top:0pt; margin-bottom:0pt;}");
  964.                 document.write("BLOCKQUOTE {margin-top:0pt; margin-bottom:0pt; margin-left:15pt;}");
  965.                 document.write("DIV {margin-top:0pt; margin-bottom:0pt;}");
  966.             }
  967.         } else {
  968.             document.write(".parent {font-size:10pt;}");
  969.             document.write("BLOCKQUOTE {margin-top:0pt; margin-bottom:0pt; margin-left:15pt;}");
  970.             document.write("P {font-family:'Arial'; font-size:8pt; margin-top:0pt; margin-bottom:0pt;}");
  971.             document.write("PRE {font-family:'Arial'; font-size:8pt; margin-top:0pt; margin-bottom:0pt;}");
  972.             document.write("DIV {margin-top:0pt; margin-bottom:0pt}");
  973.         }
  974.         document.write(".child {display:none}");
  975.         document.write("A:link {text-decoration: none; color: 000000}");
  976.         document.write("A:visited {text-decoration: none; color: 333333}");
  977.         document.write("A:active {text-decoration: none; background-color: #cccccc}");
  978.         document.write("A:hover {text-decoration: underline; color: 007f00}");
  979.     }
  980.     document.write("</STYLE>");
  981.     return;
  982. }
  983.  
  984. function TocWriteFixedWidth(bBegin, nWidth)
  985. {
  986.     //Avoid the wrap of text after book/page, make a invisble outter table is approch (for IE4 iMac only)
  987.     // This will make IE4 DHTML Sync Toc DO NOT WORK.
  988.     if ((gbIE4) && (gbMac) && (!gbIE5)) {
  989.         if (bBegin)    {
  990.             document.write("<table width=" + nWidth +" border=0><tr><td>");
  991.         } else    {
  992.             document.write("</td></tr></table>");
  993.         }
  994.     }
  995. }
  996.  
  997. //Assign the layer's visibility at initialize the Page
  998. function TocInitPage()
  999. {
  1000. //    var TocDiv = NavFrame().FindTopLevelLayer('TocNav');
  1001. //    if (TocDiv != null) {
  1002. //        return;
  1003. //    }
  1004.     if (gbNav4) {
  1005. //        for (var i=0; i < document.layers.length; i++) {
  1006. //            var whichEl = document.layers[i];
  1007. //            if (whichEl.id.indexOf("Child") != -1) {
  1008. //                whichEl.visibility = "hide";
  1009. //            } else {
  1010. //                whichEl.visibility = "show";
  1011. //            }
  1012. //        }
  1013.         TocBuildLayerArrayNS();
  1014.         onLoad  = TocArrangeAllLayerNS();
  1015.     } else if (gbIE4) {
  1016.  
  1017.         // Select the first hyperlink
  1018.         var tempColl = document.all.tags("A");
  1019.         if (tempColl.length > 0) {
  1020.             tempColl(0).focus();
  1021.         }
  1022.     }
  1023.     return;
  1024. }
  1025.  
  1026. function TocShowLayer(whichEl, bShow)
  1027. {
  1028.     if (bShow) {
  1029.         whichEl.visibility = "show";
  1030.     } else {
  1031.         whichEl.visibility = "hide";
  1032.     }
  1033.     for (var i=0; i<whichEl.document.layers.length; i++) {
  1034.         var whichChildEl = whichEl.document.layers[i];
  1035.         ShowLayer(whichChildEl, bShow);
  1036.     }
  1037. }
  1038.  
  1039. function TocExpandAll()
  1040. {
  1041.     for (var i=0; i<document.layers.length; i++) {
  1042.         var whichEl = document.layers[i];
  1043.         TocShowLayer(whichEl, true);
  1044.     }
  1045.     TocBuildLayerArrayNS();
  1046.     TocArrangeAllLayerNS();
  1047.  
  1048.     return;
  1049. }
  1050.  
  1051. function TocCollapseAll()
  1052. {
  1053.     for (var i=0; i<document.layers.length; i++) {
  1054.         var whichEl = document.layers[i];
  1055.         ShowLayer(whichEl, false);
  1056.         if (whichEl.id.indexOf("Child") != -1) {
  1057.             whichEl.visibility = "hide";
  1058.         } else {
  1059.             whichEl.visibility = "show";
  1060.         }
  1061.     }
  1062.     TocBuildLayerArrayNS();
  1063.     TocArrangeAllLayerNS();
  1064.  
  1065.     return;
  1066. }
  1067.  
  1068. //Expand a layer
  1069. function TocExpandIt(elId)
  1070. {
  1071.     TocExpandIt2(elId, false);
  1072. }
  1073.  
  1074. //Expand a layer
  1075. function TocExpandIt2(elId, bForceOpen)
  1076. {
  1077.     if (gbIE4) {
  1078.         var child = TocExpandIE(elId, true, bForceOpen);
  1079.         var nNewScroll = document.body.scrollTop;
  1080.         if (child.style.display == "block") {
  1081.             var nItemTop = child.offsetTop;
  1082.             var nItemBottom = nItemTop + child.offsetHeight;
  1083.             // Make sure the bottom is visible if possible
  1084.             if (document.body.scrollTop + document.body.clientHeight < nItemBottom) {
  1085.                 nNewScroll = nItemBottom - document.body.clientHeight;
  1086.             }
  1087.             // If expanded item is bigger than the client area, scroll the item to the top
  1088.             if (nItemBottom - nItemTop > document.body.clientHeight) {
  1089.                 nNewScroll = nItemTop - 20;
  1090.             }
  1091.         }
  1092.         document.body.scrollTop = nNewScroll;
  1093.     } else if (gbNav4) {
  1094.         TocExpandNS(elId, true, false);
  1095.         if (window.NSscrollbar != null) {
  1096.             window.NSscrollbar.SetContentHeight(nextY);
  1097.             window.NSscrollbar.SetContentWidth(nextX);
  1098.         }
  1099.     }
  1100.     return;
  1101. }
  1102.  
  1103.  
  1104. ////////////////////////////////////////////////////////////////
  1105. //Functions for IE
  1106. function TocExpandIE(elId, bChangeImg, bForceOpen) 
  1107.     var whichEl = eval(elId + "Child");
  1108.     var whichIm = document.images[elId];
  1109.  
  1110.     if (whichEl == null) {
  1111.         return null;
  1112.     }
  1113.  
  1114.     if ((whichEl.style.display != "block") || bForceOpen) {
  1115.         whichEl.style.display = "block";
  1116.         if (bChangeImg) {
  1117.             whichIm.src = imgBookOpen;        
  1118.         }
  1119.     } else {
  1120.         whichEl.style.display = "none";
  1121.         if (bChangeImg) {
  1122.             whichIm.src = imgBookClose;
  1123.         }
  1124.         if (gbMac) {
  1125.             //YJ: ?? can not scroll into view, if div has fixed width, it will scroll horizal to the very end.
  1126.             //whichEl.scrollIntoView(false);
  1127.         }
  1128.     }
  1129.     return whichEl;
  1130. }
  1131.  
  1132. ////////////////////////////////////////////////////////////////
  1133. //Functions for NS
  1134. function TocExpandNS(elId, bChangeImg, bForceOpen)
  1135. {
  1136.     var whichParent = null;
  1137.     var whichChild  = null;
  1138.     var idParent = elId + "Parent";
  1139.     var idChild  = elId + "Child";
  1140.     for (var i=0; i<elTocArrayNum ;i++) {
  1141.         if  (idParent == elTocArray[i].id) {
  1142.             whichParent = elTocArray[i].el;
  1143.  
  1144.             if ((i+1 < elTocArrayNum) && (idChild == elTocArray[i+1].id))
  1145.             {
  1146.                 whichChild = elTocArray[i+1].el;
  1147.             }
  1148.             break;
  1149.         }
  1150.     }
  1151.     if (whichParent == null)    return null;
  1152.     var imgParent = whichParent.document.images[0];
  1153.     if (whichChild == null) return null;
  1154.  
  1155.     if (whichChild.visibility == "hide")
  1156.     {
  1157.         whichChild.visibility = "show";
  1158.         if (bChangeImg) {
  1159.             imgParent.src = imgBookOpen;
  1160.         }
  1161.         for (var i=0; i<whichChild.layers.length; i++)
  1162.         {
  1163.             var whichEl = whichChild.layers[i];
  1164.             if (whichEl.id.indexOf("Parent") != -1)
  1165.                 whichEl.visibility = "show";
  1166.         }
  1167.     }
  1168.     else if (bForceOpen)
  1169.     {
  1170.         return whichChild;
  1171.     }
  1172.     else
  1173.     {
  1174.         whichChild.visibility = "hide";
  1175.         if (bChangeImg) {
  1176.             imgParent.src = imgBookClose;
  1177.         }
  1178.         for (var i=0; i<whichChild.layers.length; i++)
  1179.         {
  1180.             var whichEl = whichChild.layers[i];
  1181.             whichEl.visibility = "hide";
  1182.         }
  1183.     }
  1184.     TocArrangeAllLayerNS(bChangeImg);
  1185.     return whichChild;
  1186. }
  1187.  
  1188. function elTocLayerNS(elLayer, elLayerId)
  1189. {
  1190.     this.el  = elLayer;
  1191.     this.id  = elLayerId;
  1192.     return;
  1193. }
  1194.  
  1195. function TocFindLayerNS(elLayer)
  1196. {
  1197.     for (var i = 0; i < elLayer.layers.length; i++) {
  1198.         var whichEl = elLayer.layers[i];
  1199. //        if (typeof whichEl != "undefined") {
  1200.         if ((whichEl.id.indexOf("Parent") != -1) ||
  1201.             (whichEl.id.indexOf("Child") != -1)) {
  1202.             elTocArray[elTocArrayNum] = new elTocLayerNS(whichEl,whichEl.id);
  1203.             elTocArrayNum++;
  1204.             TocFindLayerNS(whichEl);
  1205.         }
  1206.     }
  1207.     return;
  1208. }
  1209.  
  1210. function TocBuildLayerArrayNS()
  1211. {
  1212.     elTocArrayNum = 0;
  1213.     TocFindLayerNS(document);
  1214.     return;
  1215. }
  1216.  
  1217. var  nextY = 0;
  1218. var  nextX = 0; // real means : the maxium width of sub-layers' width
  1219. function TocArrangeLayerNS(elLayer, bShowLayer, iLevel, bChangeImg)
  1220. {
  1221.     var i = 0;
  1222.     while (i < elLayer.layers.length)
  1223.     {
  1224.         var whichParent = elLayer.layers[i];
  1225.         
  1226.         if (whichParent.id.indexOf("Parent") == -1) 
  1227.             i++; // Check to make sure this is a "parent" because we do have extra layers on the page
  1228.         else
  1229.         {
  1230.             var whichChild  = elLayer.layers[i+1];
  1231.             if (bShowLayer)
  1232.             {   // Check to see if we have a second (or lower level) block with pages
  1233.                 // on top of books. If so, Netscape would ordinarily add space for the
  1234.                 // BLOCKQUOTE, but we don't want one - so remove the space.
  1235.                 if( (i == 0) && (iLevel > 0) &&
  1236.                     (null != whichParent.parentLayer) &&
  1237.                     (whichParent.parentLayer.document.images.length > 0))
  1238.                     nextY -= whichParent.document.height;
  1239.  
  1240.                 whichParent.pageY = nextY;
  1241.                 whichParent.visibility = "show";
  1242.  
  1243.                 whichParent.clip.bottom = whichParent.document.height;
  1244.                 whichParent.clip.right  = whichParent.document.width + iLevel*20;// plus indent width
  1245.                 if( whichParent.clip.right > nextX )
  1246.                     nextX = whichParent.clip.right;
  1247.  
  1248.                 nextY += whichParent.document.height;
  1249.                 if (whichChild.visibility == "show")
  1250.                 {
  1251.                     if (bChangeImg)
  1252.                         whichParent.document.images[0].src = imgBookOpen;
  1253.  
  1254.                     whichChild.pageY = nextY;
  1255.                     nextY += whichChild.document.height;
  1256.  
  1257.                     whichChild.clip.right = whichChild.document.width + iLevel*20;// plus indent width
  1258.                     if( whichChild.clip.right > nextX )
  1259.                         nextX = whichChild.clip.right;
  1260.  
  1261.                     TocArrangeLayerNS(whichChild, true, iLevel + 1, bChangeImg);
  1262.                     whichChild.clip.bottom = nextY - window.NSscrollbar.GetContentVerticalPos();
  1263.                     if( nextX > whichChild.clip.right )
  1264.                         whichChild.clip.right = nextX;
  1265.                 }
  1266.                 else
  1267.                 {
  1268.                     if (bChangeImg)
  1269.                         whichParent.document.images[0].src = imgBookClose;
  1270.  
  1271.                     TocArrangeLayerNS(whichChild, false, iLevel + 1, bChangeImg);
  1272.                 }
  1273.             }
  1274.             else
  1275.             {
  1276.                 if (bChangeImg)
  1277.                     whichParent.document.images[0].src = imgBookClose;
  1278.                 whichParent.visibility = "hide";
  1279.                 whichParent.clip.bottom = 0;
  1280.                 whichParent.clip.right  = 0;
  1281.  
  1282.                 whichChild.visibility = "hide";
  1283.                 whichChild.clip.bottom = 0;
  1284.                 whichChild.clip.right  = 0;
  1285.                 TocArrangeLayerNS(whichChild, false, iLevel, bChangeImg);
  1286.             }
  1287.             i += 2;
  1288.         }
  1289.     }
  1290.     return;
  1291. }
  1292.  
  1293. function TocArrangeAllLayerNS(bChangeImg) 
  1294. {
  1295.     if (document.layers.length > 0) {
  1296.         nextX = document.layers[0].pageX;
  1297.         nextY = document.layers[0].pageY;
  1298.         TocArrangeLayerNS(document, true, 0, bChangeImg);
  1299.     }
  1300.     return;
  1301. }
  1302.  
  1303. //////////////////////////////////////////////////////////////////////////////////////////////////////////
  1304. //
  1305. // FTS code
  1306. //
  1307. //////////////////////////////////////////////////////////////////////////////////////////////////////////
  1308.  
  1309. function FtsWriteClassStyle()
  1310. {
  1311.     document.write("<STYLE TYPE='text/css'>");
  1312.     if (gbNav4) {
  1313.         document.write("P {font-family:'Arial'; font-size:9pt;}");
  1314.         document.write("A:link {text-decoration: none; color: 000000}");
  1315.         document.write("A:visited {text-decoration: none; color: 333333}");
  1316.         document.write("A:active {text-decoration: none; background-color: #cccccc}");
  1317.         document.write("A:hover {text-decoration: underline; color: 007f00}");
  1318.     } else if (gbIE4) {
  1319.         if (gbMac) {
  1320.             if (gbIE5) {
  1321.                 document.write("P {font-family:'Arial'; font-size:10pt;}");
  1322.                 document.write("dt {font-family:'Arial'; font-size:10pt;}");
  1323.             } else {
  1324.                 document.write("P {font-family:'Arial'; font-size:12pt;}");
  1325.                 document.write("dt {font-family:'Arial'; font-size:12pt;}");
  1326.             }
  1327.         } else {
  1328.             document.write("P {font-family:'Arial'; font-size:9pt;}");
  1329.             document.write("dt {font-family:'Arial'; font-size:9pt;}");
  1330.         }
  1331.         document.write("A:link {text-decoration: none; color: 000000}");
  1332.         document.write("A:visited {text-decoration: none; color: 333333}");
  1333.         document.write("A:active {text-decoration: none; background-color: #cccccc}");
  1334.         document.write("A:hover {text-decoration: underline; color: 007f00}");
  1335.     }
  1336.     document.write("</STYLE>");
  1337.     return;
  1338. }
  1339.  
  1340. //Define variable arguments as: strKeyword [,strTopicIndex]*
  1341. //function KeywordEntry()
  1342. function FtsKeywordEntry() 
  1343. {
  1344.     var argLen = FtsKeywordEntry.arguments.length;
  1345.     this.strKeyword = FtsKeywordEntry.arguments[0];
  1346.     this.arrayTopics = new Array();
  1347.  
  1348.     // Now add all of the topic entries
  1349.     for (var i=0; i < argLen - 1; i++) {
  1350.         this.arrayTopics[i] = FtsKeywordEntry.arguments[i + 1];
  1351.     }
  1352. }
  1353.  
  1354. function FtsStopWord()
  1355. {
  1356.     this.strStopWord = FtsStopWord.arguments[0];
  1357. }
  1358.  
  1359. function FtsInputEnable(bEnable)
  1360. {
  1361.    gbFtsInputEnable = bEnable;
  1362.    return;
  1363. }
  1364.  
  1365. function FtsInputSubmit()
  1366. {
  1367.     //Hack for IE, have to use keydown to get enter event,
  1368.     //Embedding WebHelp to WinHelp2000 will fail to fire the submit the form. 
  1369.     if (!gbIE4)
  1370.     {
  1371.         FtsLookup();
  1372.     }
  1373.     return false;
  1374. }
  1375.  
  1376. //Initize the site
  1377. function FtsInit()
  1378. {
  1379.   if (!window.Array) return;
  1380.  
  1381.   if (gbNav4) document.captureEvents(Event.KEYUP);
  1382.   document.onkeyup = FtsLookupKeydown;
  1383. }
  1384.  
  1385. function FtsLookupKeydown() 
  1386. {
  1387.     if (gbIE4)
  1388.     {
  1389.         if (event.keyCode == 13)    //Enter key
  1390.         {
  1391.             FtsLookup();
  1392.         }
  1393.     }
  1394. }
  1395.  
  1396. function FtsLookup() 
  1397. {
  1398.     if (!gbFtsInputEnable && !gbMac)
  1399.         return;
  1400.  
  1401.     var strInput = document.FtsInputForm.ftsField.value.toLowerCase();
  1402.     if (strInput != "") {
  1403.         FtsDisplay(strInput);
  1404.     }
  1405.  
  1406.     if (gbMac) {
  1407.         document.FtsInputForm.ftsField.focus();
  1408.     }
  1409. }
  1410.  
  1411. var gstrDisplayInput = "";
  1412.  
  1413. function FtsFindTable()
  1414. {
  1415.     // Get the appropriate item to add items to
  1416.     var layerFind = null;
  1417.     if (gbIE4) {
  1418.         layerFind = parent.document.frames['ftsbody'].document.all.FtsFindTable;
  1419.     } else if (gbNav4) {
  1420.         layerFind = parent.document.ftsbody.document.FtsFindTable.document;
  1421.     }
  1422.     
  1423.     return layerFind;
  1424. }
  1425.  
  1426. function FtsBody()
  1427. {
  1428.     // Get the appropriate item to add items to
  1429.     var layerFind = null;
  1430.     if (gbIE4) {
  1431.         layerFind = parent.document.frames['ftsbody'];
  1432.     } else if (gbNav4) {
  1433.         layerFind = parent.document.ftsbody.document;
  1434.     }
  1435.     
  1436.     return layerFind;
  1437. }
  1438.  
  1439. function FtsDisplay(strInput)
  1440. {
  1441.     var layerFind = FtsFindTable();
  1442.     if (layerFind == null) {
  1443.         return;
  1444.     }
  1445.  
  1446.     // Let the user know we are busy
  1447.     var strHtm = "<P><B><FONT SIZE=2>Finding topics...</FONT></B></P>"
  1448.     if (gbIE4) {
  1449.         layerFind.innerHTML = strHtm;
  1450.     } else if (gbNav4) {
  1451.         layerFind.write(strHtm);
  1452.         layerFind.close();
  1453.     }
  1454.     window.gstrDisplayInput = strInput;
  1455.     setTimeout("FtsDisplayReal()", 50);
  1456.  
  1457.     return;
  1458. }
  1459.  
  1460. function FtsDisplayReal()
  1461. {
  1462.     var FtsDiv = FtsBody();
  1463. //    if (gbNav4) {
  1464. //        FtsDiv = FindTopLevelLayer('FtsNav');
  1465. //    } else if (gbIE4) {
  1466. //        FtsDiv = parent.parent.FindTopLevelLayer('FtsNav');
  1467. //        FtsDiv = FtsDiv.document.frames['FtsIFrame'].document.all.ftsbody;
  1468. //    }
  1469.  
  1470.     var strInput = window.gstrDisplayInput;
  1471.     var nKeywordArrayLen = FtsDiv.gFtsKeywordArray.length;
  1472.     var nTopicArrayLen = FtsDiv.gFtsTopicArray.length;
  1473.     var nStopArrayLen = FtsDiv.gFtsStopArray.length;
  1474.  
  1475.     // Get the appropriate item to add items to
  1476.     var layerFind = FtsFindTable();
  1477.     if (layerFind == null) {
  1478.         return;
  1479.     }
  1480.  
  1481.     // Keep track of which operation we are currently in
  1482.     // 0 = OR; 1 = AND
  1483.     var nCurrentOp = 0;
  1484.     var bNot = false;
  1485.  
  1486.     // Loop through the words in the input string
  1487.     var bFinished = false;
  1488.     var bFirstKeyword = true;
  1489.     var strCurrentWord = "";
  1490.     var strCurrentStem = "";
  1491.     var strKeyword = "";
  1492.     var strHtm = "";
  1493.     var nFirstMatch = -1;
  1494.     var nLastMatch  = -1;
  1495.     var i=0;
  1496.     var iSpace = 0;
  1497.     var iFound = 0;
  1498.     var SearchTopicArray = new Array();
  1499.     var iSearch = 0;
  1500.     // If you change this Word Break string make sure you also change it in FtsDataBase.CPP
  1501.     var FTS_WORD_BREAK_CHARS = "\t\r\n\"\\ .,!@#$%^&*()~'`:;<>?/{}[]|+-=\x85\x92\x93\x94\x95\x96\x97\x99\xA9\xAE\xB7";
  1502.     var nNumWordBreakChars = FTS_WORD_BREAK_CHARS.length;
  1503.  
  1504.     // Clear the flags for each of the topics
  1505.     var iTopic = 0;
  1506.     for (iTopic = 0; iTopic < nTopicArrayLen; iTopic++) {
  1507.         SearchTopicArray[iTopic] = 0;
  1508.     }
  1509.  
  1510.     while (!bFinished) {
  1511.  
  1512.         // Get the next word
  1513.         iSpace = -1;
  1514.         iChar = 0;
  1515.         iSep = -1;
  1516.         for (var iChar = 0; iChar < nNumWordBreakChars; iChar++) {
  1517.             iFound = strInput.indexOf(FTS_WORD_BREAK_CHARS.charAt(iChar));
  1518.             if ((iFound != -1) && ((iSpace == -1) || (iFound < iSpace))) {
  1519.                 iSpace = iFound;
  1520.                 iSep = iChar;
  1521.             }
  1522.         }
  1523.         if (iSpace == -1) {
  1524.             strCurrentWord = strInput;
  1525.             strInput = "";
  1526.         } else {
  1527.             strCurrentWord = strInput.substr(0, iSpace);
  1528.             strInput = strInput.substr(iSpace + 1);
  1529.         }
  1530.  
  1531.         // Check for operators or a blank word
  1532.         if ((strCurrentWord == "or") ||
  1533.                ((iSep >= 0) && (FTS_WORD_BREAK_CHARS.charAt(iSep) == "|"))) {
  1534.             nCurrentOp = 0;
  1535.             bNot = false;
  1536.         } else if ((strCurrentWord == "and") ||
  1537.                ((iSep >= 0) && (FTS_WORD_BREAK_CHARS.charAt(iSep) == "&"))) {
  1538.             nCurrentOp = 1;
  1539.             bNot = false;
  1540.         } else if ((strCurrentWord == "not") ||
  1541.                ((iSep >= 0) && (FTS_WORD_BREAK_CHARS.charAt(iSep) == "~"))) {
  1542.             bNot = true;
  1543.         } else if (strCurrentWord == "") {
  1544.             if (strInput == "") {
  1545.                 break;
  1546.             } else {
  1547.                 continue;
  1548.             }
  1549.         } else if (!IsStopWord(strCurrentWord, FtsDiv.gFtsStopArray, nStopArrayLen)){
  1550.  
  1551.             // See if this is has a NOT at the beginning
  1552.             if (strCurrentWord.substr(0, 1) == "~") {
  1553.                 bNot = true;
  1554.                 strCurrentWord = strCurrentWord.substr(1);
  1555.             }
  1556.  
  1557.             // Get the stemmed version of the word
  1558.             strCurrentStem = GetStem(strCurrentWord);
  1559.  
  1560.             // See if the stemmed word is found in the list
  1561.             iFound = -1;
  1562.             iFound = FtsFindKeyword(strCurrentStem, FtsDiv.gFtsKeywordArray, nKeywordArrayLen);
  1563.  
  1564.             // Did we find the keyword?
  1565.             if (iFound != -1) {
  1566.  
  1567.                 // See if we are performing an OR operation
  1568.                 var nNumTopics = FtsDiv.gFtsKeywordArray[iFound].arrayTopics.length;
  1569.                 if (nCurrentOp == 0) {
  1570.                     if (bNot) {
  1571.                         var cFoundArrayTopics =  FtsDiv.gFtsKeywordArray[iFound].arrayTopics;
  1572.                         // Add all topics that are not in the list for this keyword
  1573.                         for (iTopic = 0; iTopic < nTopicArrayLen; iTopic++) {
  1574.                             // See if the topic is in the list for this keyword
  1575.                             for (iListTopic = 0; iListTopic < nNumTopics; iListTopic++) {
  1576.                                 if (cFoundArrayTopics[iListTopic] == iTopic) {
  1577.                                     break;
  1578.                                 }
  1579.                             }
  1580.                             if (iListTopic == nNumTopics) {
  1581.                                 // The topic is not in the list for the current keyword, so add it
  1582.                                 SearchTopicArray[iTopic] = 1;
  1583.                             }
  1584.                         }
  1585.  
  1586.                     } else {
  1587.                         // Loop through the topics that have the keyword and add them to the list
  1588.                         for (iTopic = 0; iTopic < nNumTopics; iTopic++) {
  1589.                             var nTopicNum = FtsDiv.gFtsKeywordArray[iFound].arrayTopics[iTopic];
  1590.                             // Add the topic to the list
  1591.                             SearchTopicArray[nTopicNum] = 1;
  1592.                         }
  1593.                     }
  1594.                 // See if this is an AND operation
  1595.                 } else if (nCurrentOp == 1) {
  1596.  
  1597.                     if (bNot) {
  1598.                         // Loop through the topics for the current word and remove them from the list
  1599.                         for (iTopic = 0; iTopic < nNumTopics; iTopic++) {
  1600.                             SearchTopicArray[FtsDiv.gFtsKeywordArray[iFound].arrayTopics[iTopic]] = 0;
  1601.                         }
  1602.                     } else {
  1603.                         // Loop through the topics already in the list and remove them if they are not
  1604.                         // in the list for the current word
  1605.                         for (iTopic = 0; iTopic < nNumTopics; iTopic++) {
  1606.                             if (SearchTopicArray[FtsDiv.gFtsKeywordArray[iFound].arrayTopics[iTopic]] == 1) {
  1607.                                 SearchTopicArray[FtsDiv.gFtsKeywordArray[iFound].arrayTopics[iTopic]] = -1;
  1608.                             }
  1609.                         }
  1610.                         for (iTopic = 0; iTopic < nTopicArrayLen; iTopic++) {
  1611.                             if (SearchTopicArray[iTopic] == -1) {
  1612.                                 SearchTopicArray[iTopic] = 1;
  1613.                             } else {
  1614.                                 SearchTopicArray[iTopic] = 0;
  1615.                             }
  1616.                         }
  1617.                     }
  1618.                 }
  1619.             } else {
  1620.                 // Word was not found
  1621.  
  1622.                 // Clear the list if this is an AND operation
  1623.                 if ((nCurrentOp == 1) && (!bNot)) {
  1624.                     for (iSearch = 0; iSearch < nTopicArrayLen; iSearch++) {
  1625.                         SearchTopicArray[iSearch] = 0;
  1626.                     }
  1627.  
  1628.                 // Add all items to the list if this is an OR operation with a NOT operator
  1629.                 } else if ((nCurrentOp == 0) && (bNot)) {
  1630.  
  1631.                     // Add all topics that are not in the list for this keyword
  1632.  
  1633.                     // First set all flags to -1 if they are not already set
  1634.                     for (iTopic = 0; iTopic < nTopicArrayLen; iTopic++) {
  1635.                         if (SearchTopicArray[iTopic] == 0) {
  1636.                             SearchTopicArray[iTopic] = -1;
  1637.                         }
  1638.                     }
  1639.  
  1640.                     // Now clear all -1s for topics associated with this keyword
  1641.                     for (iTopic = 0; iTopic < nNumTopics; iTopic++) {
  1642.                         if (SearchTopicArray[FtsDiv.gFtsKeywordArray[iFound].arrayTopics[iTopic]] == -1) {
  1643.                             SearchTopicArray[FtsDiv.gFtsKeywordArray[iFound].arrayTopics[iTopic]] = 0;
  1644.                         }
  1645.                     }
  1646.  
  1647.                     // Finally change all -1s to 1s
  1648.                     for (iTopic = 0; iTopic < nTopicArrayLen; iTopic++) {
  1649.                         if (SearchTopicArray[iTopic] == -1) {
  1650.                             SearchTopicArray[iTopic] = 1;
  1651.                         }
  1652.                     }
  1653.                 }
  1654.             }
  1655.  
  1656.             // If this was the first word change the operation to "and". We need to have it be
  1657.             // an "or" for the first keyword so we would add the items for the first search word.
  1658.             if (bFirstKeyword) {
  1659.                 bFirstKeyword = false;
  1660.                 nCurrentOp = 1;
  1661.             }
  1662.         }
  1663.     }
  1664.  
  1665.     var aSortedTopics = new Array();
  1666.     var nNumSortTopics = 0;
  1667.     for (iSearch = 0; iSearch < nTopicArrayLen; iSearch++) {
  1668.         if (SearchTopicArray[iSearch]) {
  1669.             aSortedTopics[nNumSortTopics++] = iSearch;
  1670.         }
  1671.     }
  1672.  
  1673.     // Limit the number of topics in the result set
  1674.     if (nNumSortTopics > 75) {
  1675.         nNumSortTopics = 75;
  1676.     }
  1677.  
  1678.     // Sort the topics by title
  1679.     SortTopics(FtsDiv, aSortedTopics, 0, nNumSortTopics - 1);
  1680.  
  1681.     // Add hyperlinks for all of the found topics
  1682.     var strLine = "";
  1683.     for (iSearch = 0; iSearch < nNumSortTopics; iSearch++) {
  1684.         i = aSortedTopics[iSearch];
  1685.         if (i != -1) {
  1686.             strLine = "<dt><nobr><a href='" + FtsDiv.gFtsTopicArray[i].strURL + "'>";
  1687.             strLine += FtsDiv.gFtsTopicArray[i].strTitle; 
  1688.             strLine += "</a></nobr></dt>";
  1689.             strHtm += strLine;
  1690.         }
  1691.     }
  1692.  
  1693.     // Give a special message if none were found
  1694.     if (strHtm == "") {
  1695.         strHtm = "<P><B>No topics found.</B></P>"
  1696.     } else {
  1697.         strHtm = "<dl>" + strHtm + "</dl>";
  1698.     }
  1699.  
  1700.     if (gbIE4) {
  1701.         layerFind.innerHTML = strHtm;
  1702.     } else if (gbNav4) {
  1703.         layerFind.write(strHtm);
  1704.         layerFind.close();
  1705.     }
  1706.  
  1707.     return;
  1708. }
  1709.  
  1710.  
  1711. function FtsFindKeyword(strCurrentWord, aFtsKeywordArray, nKeywordArrayLen)
  1712. {
  1713.     // Search for the current word in the array (binary search)
  1714.     var nLow = 0; 
  1715.     var nHigh = nKeywordArrayLen - 1;
  1716.     var nMid = 0;
  1717.     var bFound = false;
  1718.     var strKeyword = "";
  1719.     while (nLow <= nHigh) {
  1720.         nMid = (nLow + nHigh);
  1721.         nMid >>= 1;
  1722.         strKeyword = aFtsKeywordArray[nMid].strKeyword;
  1723.         if (strCurrentWord > strKeyword) {
  1724.             nLow = (nLow == nMid) ? nMid + 1 : nMid;
  1725.         } else {
  1726.             if (strCurrentWord < strKeyword)  {
  1727.                 nHigh = (nHigh == nMid) ? nMid - 1: nMid;
  1728.             } else {
  1729.                 bFound = true;
  1730.                 break;
  1731.             }
  1732.         }
  1733.     }
  1734.  
  1735.     if (bFound) {
  1736.         return nMid;
  1737.     } else {
  1738.         return -1;
  1739.     }
  1740. }
  1741.  
  1742.  
  1743. // QuickSort
  1744. function SortTopics(FtsDiv, SearchTopicArray, nStart, nEnd)
  1745. {
  1746.     if (nEnd - nStart > 0) {
  1747.         var nLastLow = nStart;
  1748.  
  1749.         // Get the first value into its proper spot
  1750.         for (var i = nStart + 1; i <= nEnd; i++) {
  1751.             if ((SearchTopicArray[i] != -1) && (SearchTopicArray[nStart] != -1) &&
  1752.                 (FtsDiv.gFtsTopicArray[SearchTopicArray[i]].strTitle < FtsDiv.gFtsTopicArray[SearchTopicArray[nStart]].strTitle)) {
  1753.                 nLastLow++;
  1754.                 temp = SearchTopicArray[i];
  1755.                 SearchTopicArray[i] = SearchTopicArray[nLastLow];
  1756.                 SearchTopicArray[nLastLow] = temp;
  1757.             }
  1758.         }
  1759.         temp = SearchTopicArray[nStart];
  1760.         SearchTopicArray[nStart] = SearchTopicArray[nLastLow];
  1761.         SearchTopicArray[nLastLow] = temp;
  1762.  
  1763.         // Sort the two halves of this array surrounding the new spot for the first value
  1764.         SortTopics(FtsDiv, SearchTopicArray, nStart, nLastLow);
  1765.         SortTopics(FtsDiv, SearchTopicArray, nLastLow + 1, nEnd);
  1766.     }
  1767. }
  1768.  
  1769. function IsStopWord(strCurrentWord, aFtsStopArray, nStopArrayLen)
  1770. {
  1771.     // Search for the current word in the array (binary search)
  1772.     var nLow = 0; 
  1773.     var nHigh = nStopArrayLen - 1;
  1774.     var nMid = 0;
  1775.     var bFound = false;
  1776.     var strStopWord = "";
  1777.     while (nLow <= nHigh) {
  1778.         nMid = (nLow + nHigh);
  1779.         nMid >>= 1;
  1780.         strStopWord = aFtsStopArray[nMid].strStopWord;
  1781.         if (strCurrentWord > strStopWord) {
  1782.             nLow = (nLow == nMid) ? nMid + 1 : nMid;
  1783.         } else {
  1784.             if (strCurrentWord < strStopWord) {
  1785.                 nHigh = (nHigh == nMid) ? nMid - 1: nMid;
  1786.             } else {
  1787.                 bFound = true;
  1788.                 break;
  1789.             }
  1790.         }
  1791.     }
  1792.  
  1793.     if (bFound) {
  1794.         return true;
  1795.     } else {
  1796.         return false;
  1797.     }
  1798. }
  1799.  
  1800.  
  1801. /////////////////////////////////////////////////////////////
  1802. //
  1803. // NOTE: If you change this function, you should also change
  1804. // it in the FtsDatabase.CPP file
  1805. //
  1806. /////////////////////////////////////////////////////////////
  1807. function GetStem(szWord)
  1808. {
  1809.     var aStems = new Array();
  1810.     aStems[0] = "ed";
  1811.     aStems[1] = "es";
  1812.     aStems[2] = "er";
  1813.     aStems[3] = "e";
  1814.     aStems[4] = "s";
  1815.     aStems[5] = "ingly";
  1816.     aStems[6] = "ing";
  1817.     aStems[7] = "ly";
  1818.  
  1819.     // Loop through all the stems
  1820.     var nNumStems = aStems.length;
  1821.     var    nStemPos = 0;
  1822.     var csStem = "";
  1823.     var csSubString = "";
  1824.     for (var iStem = 0; iStem < nNumStems; iStem++) {
  1825.  
  1826.         // Get the "would be" position of the stem in the word and see
  1827.         // if this word has the stem
  1828.         nStemPos = szWord.lastIndexOf(aStems[iStem]);
  1829.         if (nStemPos > 0) {
  1830.             csSubString = szWord.substring(nStemPos);
  1831.             if (csSubString == aStems[iStem]) {
  1832.                 
  1833.                 // Found a stem
  1834.  
  1835.                 // Check for double consonant
  1836.                 csStem = szWord;
  1837.                 if (szWord.charAt(nStemPos - 2) == szWord.charAt(nStemPos - 1)) {
  1838.                     csStem = csStem.substring(0, nStemPos - 1);
  1839.                 } else {
  1840.                     csStem = csStem.substring(0, nStemPos);
  1841.                 }
  1842.                 return csStem;
  1843.             }
  1844.         }
  1845.     }
  1846.  
  1847.     // No stem found
  1848.     csStem = szWord;
  1849.     return csStem;
  1850. }
  1851.  
  1852. ////////////////////////////////////////////////////////////////////////////////////////////////
  1853. //
  1854. // Navgation Bar Code
  1855. //
  1856. ////////////////////////////////////////////////////////////////////////////////////////////////
  1857.  
  1858. function NavBar_SelectTOC()
  1859. {
  1860.     var frameLeft = null
  1861.     if (gbNav4) {
  1862.         frameLeft = window.parent.left;
  1863.     } else {
  1864.         frameLeft = window.parent.frames("left");
  1865.     }
  1866.     frameLeft.ChangeToTOC();
  1867. }
  1868.  
  1869. function NavBar_SelectIndex()
  1870. {
  1871.     var frameLeft = null
  1872.     if (gbNav4) {
  1873.         frameLeft = window.parent.left;
  1874.     } else {
  1875.         frameLeft = window.parent.frames("left");
  1876.     }
  1877.     frameLeft.ChangeToIndex();
  1878. }
  1879.  
  1880. ////////////////////////////////////////////////////////////////////////////////////////////////
  1881. //
  1882. // Function support sync toc for DHTML
  1883. //
  1884. ////////////////////////////////////////////////////////////////////////////////////////////////
  1885.  
  1886. function NavBar_SyncToc(strRelURL)
  1887. {
  1888.     var strHomeURL = location.href;
  1889.     if (location.hash.length > 0) 
  1890.         strHomeURL = location.href.substring(0, location.href.indexOf("#"));
  1891.  
  1892.     var strHomePath = strHomeURL.substring(0, strHomeURL.lastIndexOf("/"));
  1893.     var strAbsURL = strHomePath + "/" + strRelURL;
  1894.  
  1895.     var containTags = new Array();
  1896.     strAbsURL = NavBar_ReplaceSlash(strAbsURL);
  1897.     var res = NavBar_SearchToc(document.body, strAbsURL, containTags, 0);
  1898.     if (res >= 0) 
  1899.     {
  1900.         for (i = 0; i < res; i ++ ) {
  1901.             var elId = containTags[i].id;
  1902.             elId = elId.substring(0, elId.indexOf("Child"));
  1903.             TocExpandIt2(elId, true);
  1904.         }
  1905.         containTags[res].focus();
  1906.     }
  1907. }
  1908.  
  1909. // if the DHTML structure changed . the following code MUST MODIFY.
  1910. // Currently do not support IE4.5 on Mac. because on iMac we will capsulate all the contents in a <TABLE>.
  1911. // for IE 4.5 will wrap text which is not good for us.
  1912. // so if want to enable IE4.5. something need to take care here.
  1913. // now we are using Applet for IE 4.5 instead of DHTML for some other reasons.
  1914. function NavBar_SearchToc(tagsObject, strAbsURL, containTags, level)
  1915. {
  1916.     var i = 0;
  1917.     var j = 0;
  1918.     var collBlock = tagsObject.children.tags("BLOCKQUOTE");
  1919.     if (collBlock != null) {
  1920.         for (i = 0; i < collBlock.length ; i ++ )
  1921.         {
  1922.             // here we assume each BLOCKQUOTE has one and only one DIV
  1923.             containTags[level] = collBlock[i].children.tags("DIV")[0];
  1924.             var res = NavBar_SearchToc(containTags[level], strAbsURL, containTags, level + 1);
  1925.             if (res != -1)
  1926.                 return res;
  1927.         }
  1928.  
  1929.     }
  1930.     var collA = tagsObject.all.tags("A");
  1931.     if (collA != null) {
  1932.         for (j = 0; j < collA.length; j ++ )
  1933.         {
  1934.             var hrefURL = NavBar_ReplaceSlash(collA[j].href);
  1935.             if (hrefURL == strAbsURL)
  1936.             {
  1937.                 containTags[level] = collA[j];
  1938.                 return level;
  1939.             }
  1940.         }
  1941.  
  1942.     }
  1943.     return -1;
  1944. }
  1945.  
  1946. // replace \\ to /
  1947. function NavBar_ReplaceSlash(strURL)
  1948. {    
  1949.     var strReplacedURL = "";
  1950.     for (i = 0; i < strURL.length; i ++ )
  1951.     {
  1952.         if (strURL.charAt(i) == '\\') 
  1953.             strReplacedURL = strReplacedURL + "/"
  1954.         else
  1955.             strReplacedURL = strReplacedURL + strURL.charAt(i);
  1956.     }
  1957.     return strReplacedURL;
  1958. }
  1959.